﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter21.ViewModel
{
    using System.Data;
    using System.Windows;
    using System.Windows.Controls;

    public class SingleCriteriaHighlightStyleSelector : StyleSelector
    {
        public Style DefaultStyle { get; set; }
        public Style HighlightStyle { get; set; }
        public string PropertyToEvaluate { get; set; }
        public string PropertyValueToHighlight { get; set; }

        public override Style SelectStyle(object item, DependencyObject container)
        {
            var product = (DataRowView)item;
            if (product[PropertyToEvaluate].ToString() == PropertyValueToHighlight)
            {
                return HighlightStyle;
            }
            else
            {
                return DefaultStyle;
            }
        }
    }
}
